package com.zs.lib_base.model

import android.graphics.Color
import androidx.databinding.BaseObservable
import com.zs.lib_base.utils.NumberFormat1

/**
 * descrition:
 */
class SouthestDetailHeadModel : BaseObservable(){
    val titleName: String? = null
    val indexDay: String? = null
    var indexPrice: String? = null
        get() = if(field.isNullOrEmpty()) "-" else NumberFormat1(field?:"")
    var indexPriceWave: String? = null

//    var indexPriceWaveFormat: String? = null
//        get() = if(indexPriceWave.isNullOrEmpty()) "-" else NumberFormat1(indexPriceWave?:"0")
    var indexPriceWaveFormat: String? = null
        get() = if(indexPriceWave.isNullOrEmpty()) "-" else if(titleName?.contains("环比上月") == true || titleName?.contains("同比去年") == true)
            "${NumberFormat1(indexPriceWave?:"0")}%" else NumberFormat1(indexPriceWave?:"0")


    val headList: MutableList<String>? = null
    val list: MutableList<String>? = null

    val color
        get() = when {
            indexPriceWave?.toFloatOrNull() ?: 0f > 0 -> {
                Color.parseColor("#FF4D5E")
            }
            indexPriceWave?.toFloatOrNull() ?: 0f < 0 -> {
                Color.parseColor("#0AB96B")
            }
            else -> {
                Color.parseColor("#7E7E7E")
            }
        }
}